package io.renren.modules.materialcopy.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.renren.modules.poschangedata.entity.PoschangeDataCopy1Entity;
import io.renren.modules.welderunnormal.entity.WelderunnormalEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.materialcopy.entity.MaterialTestCopy1Entity;
import io.renren.modules.materialcopy.service.MaterialTestCopy1Service;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-07-14 15:12:45
 */
@RestController
@RequestMapping("materialcopy/materialtestcopy1")
public class MaterialTestCopy1Controller {
    @Autowired
    private MaterialTestCopy1Service materialTestCopy1Service;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("materialcopy:materialtestcopy1:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = materialTestCopy1Service.queryPage(params);

        return R.ok().put("page", page);
    }

    //弹窗获取物料流转信息
    @GetMapping("listMaterialFlowInfo")
    public List<PoschangeDataCopy1Entity> listMaterialFlowInfo(@RequestParam(value = "productNo",required = false) String productNo){
        return materialTestCopy1Service.listMaterialFlowInfo(productNo);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{productno}")
    @RequiresPermissions("materialcopy:materialtestcopy1:info")
    public R info(@PathVariable("productno") String productno){
		MaterialTestCopy1Entity materialTestCopy1 = materialTestCopy1Service.getById(productno);

        return R.ok().put("materialTestCopy1", materialTestCopy1);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("materialcopy:materialtestcopy1:save")
    public R save(@RequestBody MaterialTestCopy1Entity materialTestCopy1){
//		materialTestCopy1Service.save(materialTestCopy1);
		materialTestCopy1Service.insertMaterial(materialTestCopy1);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("materialcopy:materialtestcopy1:update")
    public R update(@RequestBody MaterialTestCopy1Entity materialTestCopy1){
		materialTestCopy1Service.updateById(materialTestCopy1);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("materialcopy:materialtestcopy1:delete")
    public R delete(@RequestBody String[] productnos){
		materialTestCopy1Service.removeByIds(Arrays.asList(productnos));

        return R.ok();
    }

}
